// 管理员登录接口
const express = require('express');
const router = express.Router();
const db = require('../../db/connect');
const xzid = require('xzid');
const dayjs = require("dayjs");

router.post('/admin/InsertTitle', (req, res) => {
    const { title,content,img,state } = req.query;
    // console.log(req.query)
    const now = dayjs().format('YYYY-MM-DD HH:mm:ss');
    const sql = `INSERT INTO manger_title (title_id,title,title_time,title_content,title_img,title_state) VALUES
     (?,?,?,?,?,?);
    `;
    db(sql, [xzid(), title,now, content,img,state ], (err, data) => {
        if (data.affectedRows !== 0) {
            res.send({
                data,
                code: 200
            })
        } else {
            res.send({
                code: 400,
                content: err,
                message: '告诉他账户不存在'
            })
        }
    })
})
module.exports = router